<?php

class Controller_Delete
{
    protected $mapper = null;
    
    public function __construct()
    {
        require_once '../model/db.php';
        require_once '../model/mapper.php';
        require_once '../model/entry.php';
        
        // create instances
        $this->mapper = new MapperEntry();
    }
    
    public function index()
    {
        $id = $_GET["id"] ? $_GET["id"] : null;
        if ($id) {
            $deleteEntry = $this->mapper->deleteEntrieById($id);
            // deleted successfully
            if ($deleteEntry) {
                header('Location: /select');
            }
        }
    }
}